package com.chaoyer.cynet;

import com.chaoyer.cynet.access.AccessServerBootStrap;
import com.chaoyer.cynet.cache.GhostPostCache;
import com.chaoyer.cynet.common.help.SpringHelper;
import com.chaoyer.cynet.common.route.RouterMapping;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
class ApplicationInit implements CommandLineRunner {

    @Override
    public void run(String... strings) throws Exception {

        ApplicationContext ac = SpringHelper.getApplicationContext();

        RouterMapping.register(ac);                                   // 注册路由

        SpringHelper.getBean(GhostPostCache.class).init();        // ghostPost缓存

        SpringHelper.getBean(AccessServerBootStrap.class).start();   // netty启动
    }
}